package Hash;

import java.util.HashMap;
import java.util.Map;

public class TwoSum1 {
    public int[] twoSum(int[] nums, int target){
        Map<Integer, Integer> map = new HashMap<>();
        int[] ints = new int[2];
        int temp = 0;
        for(int i = 0;i< nums.length;i++){
            temp = target - nums[i];
            if(!map.containsKey(temp)){
                map.put(nums[i],i);
            }else{
                ints[0] = i;
                ints[1] = map.get(temp);
            }
        }
        return ints;
    }
}
